package com.techstar.api.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.techstar.api.service.bus.TodayHourChargeTrendService;
import com.techstar.api.service.bus.DailyBusinessRankService;
import com.techstar.api.service.bus.DailyBusinessService;
import com.techstar.api.service.bus.TodayDistrictOdService;
import com.techstar.api.service.bus.DailyHourChargeTrendService;
import com.techstar.api.service.bus.MonthDayTrafficTrendService;
import com.techstar.api.service.bus.NetStatisticsInfoService;
import com.techstar.api.service.bus.RealtimeChargeService;
import com.techstar.api.service.bus.RealtimeDispatchService;
import com.techstar.api.service.bus.RealtimeTrafficService;
import com.techstar.api.service.bus.TodayHourDispatchTrendService;
import com.techstar.api.service.bus.TodayHourTrafficTrendService;
import com.techstar.api.service.bus.TodayTimeExecutionRankService;
import com.techstar.api.service.bus.TodayTrafficRankService;
import com.techstar.api.service.bus.WorkdayHourDispatchTrendService;
import com.techstar.api.service.bus.WorkdayHourTrafficTrendService;
import com.techstar.api.service.bus.YearlyDailyBusinessTrendService;
import com.techstar.api.service.onlinecar.OnlinecarDailyBusinessService;
import com.techstar.api.service.onlinecar.OnlinecarMonthBusinessPercarTrendService;
import com.techstar.api.service.onlinecar.OnlinecarMonthEnterpriseBusinessRankService;
import com.techstar.api.service.onlinecar.OnlinecarMonthEnterpriseViolationRankService;
import com.techstar.api.service.onlinecar.OnlinecarMouthViolationTypeService;
import com.techstar.api.service.onlinecar.OnlinecarRealtimeVehicleService;
import com.techstar.api.service.onlinecar.OnlinecarRegistrationInfoService;
import com.techstar.api.service.onlinecar.OnlinecarTodayAreaVehicleRankService;
import com.techstar.api.service.onlinecar.OnlinecarTodayLoadStatusTrendService;
import com.techstar.api.service.overview.OverviewRealtimeTrafficService;
import com.techstar.api.service.overview.OverviewRealtimeTransportationService;
import com.techstar.api.service.overview.OverviewTodayHourTrafficTrendService;
import com.techstar.api.service.overview.OverviewTrafficEventService;
import com.techstar.api.service.overview.OverviewYearlyTrafficTrendService;
import com.techstar.api.service.subway.SubwayLineBusinessRankService;
import com.techstar.api.service.subway.SubwayLineStationLoadService;
import com.techstar.api.service.subway.SubwayNetStatisticsInfoService;
import com.techstar.api.service.subway.SubwayRealtimeTrafficService;
import com.techstar.api.service.subway.SubwayStationLoadRankService;
import com.techstar.api.service.subway.SubwayTodayHourTrafficTrendService;
import com.techstar.api.service.subway.SubwayTodayLineTrafficRankService;
import com.techstar.api.service.subway.SubwayTodayStationTrafficRankService;
import com.techstar.api.service.taxi.TaxiDailyBusinessService;
import com.techstar.api.service.taxi.TaxiMonthBusinessPercarTrendService;
import com.techstar.api.service.taxi.TaxiMonthEnterpriseViolationRankService;
import com.techstar.api.service.taxi.TaxiMonthViolationTypeService;
import com.techstar.api.service.taxi.TaxiRealtimeVehicleService;
import com.techstar.api.service.taxi.TaxiTodayAreaVehicleRankService;
import com.techstar.api.service.taxi.TaxiTodayDistrictOdService;
import com.techstar.api.service.taxi.TaxiTodayLoadStatusTrendService;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.List;

/**
 * 
 * @author EinIce
 * @description API接口启动配置
 * @date 2021年7月16日
 *
 */
@Slf4j
@Service
public class TrafficFactory {
//	private List<String> distId = Arrays.asList("4553","5318","5319","5320","5321","5322","5323","5324","5325","5326");
	private List<String> line_codes = Arrays.asList("0000","0001","0002","0003","0004","0005","0006","0007","0008","0009");
	private List<String> types = Arrays.asList("2", "3");
	@Autowired
	private NetStatisticsInfoService NetStatisticsInfoService;
	@Autowired
	private RealtimeDispatchService RealtimeDispatchService;
	@Autowired
	private RealtimeTrafficService RealtimeTrafficService;
	@Autowired
	private WorkdayHourDispatchTrendService WorkdayHourDispatchTrendService;
	@Autowired
	private WorkdayHourTrafficTrendService WorkdayHourTrafficTrendService;
	@Autowired
	private TodayHourChargeTrendService TodayHourChargeTrendService;
	@Autowired
	private DailyBusinessRankService DailyBusinessRankService;
	@Autowired
	private DailyBusinessService DailyBusinessService;
	@Autowired
	private TodayDistrictOdService DailyDistrictOdService;
	@Autowired
	private DailyHourChargeTrendService DailyHourChargeTrendService;
	@Autowired
	private MonthDayTrafficTrendService MonthDayTrafficTrendService;
	@Autowired
	private RealtimeChargeService RealtimeChargeService;
	@Autowired
	private TodayHourDispatchTrendService TodayHourDispatchTrendService;
	@Autowired
	private TodayHourTrafficTrendService TodayHourTrafficTrendService;
	@Autowired
	private TodayTimeExecutionRankService TodayTimeExecutionRankService;
	@Autowired
	private TodayTrafficRankService TodayTrafficRankService;
	@Autowired
	private YearlyDailyBusinessTrendService YearlyDailyBusinessTrendService;
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void bus5Service() {
		log.info("Bus 5min Service Start!");
		RealtimeTrafficService.query();
		RealtimeDispatchService.query();
		DailyDistrictOdService.query();
		log.info("Bus 5min Service Finish!");
	}
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void bus10Service() {
		log.info("Bus 10min Service Start!");
		log.info("Bus 10min Service Finish!");
	}
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void bus20Service() {
		log.info("Bus 20min Service Start!");
		TodayHourDispatchTrendService.query();
		TodayHourTrafficTrendService.query();
//		请求多种类型
		types.forEach(l->TodayTrafficRankService.query(l));
		WorkdayHourTrafficTrendService.query();
		TodayTimeExecutionRankService.query();
		WorkdayHourDispatchTrendService.query();
		DailyBusinessRankService.query();
		RealtimeChargeService.query();
		TodayHourChargeTrendService.query();
		log.info("Bus 20min Service Finish!");
	}
	@Scheduled(fixedDelay = 3 * 60 * 60 * 1000)
	public void bus3HourService() {
		log.info("Bus 3hour Service Start!");
		MonthDayTrafficTrendService.query();
		DailyBusinessService.query();
		DailyHourChargeTrendService.query();
		log.info("Bus 3hour Service Finish!");
	}
	@Scheduled(fixedDelay = 24 * 60 * 60 * 1000)
	public void busDayService() {
		log.info("Bus Day Service Start!");
		NetStatisticsInfoService.query();
		YearlyDailyBusinessTrendService.query();
		log.info("Bus Day Service Finish!");
	}
	
	@Autowired
	private OnlinecarTodayAreaVehicleRankService onlinecarCurrentDistrictVehicleRankService;
	@Autowired
	private OnlinecarDailyBusinessService onlinecarDailyBusinessService;
	@Autowired
	private OnlinecarTodayLoadStatusTrendService onlinecarDailyHourVehicleTrendService;
	@Autowired
	private OnlinecarMonthEnterpriseBusinessRankService onlinecarEnterpriseBusinessRankService;
	@Autowired
	private OnlinecarMonthEnterpriseViolationRankService onlinecarEnterpriseViolationRankService;
	@Autowired
	private OnlinecarMonthBusinessPercarTrendService onlinecarMonthlyDailyCarTrendService;
	@Autowired
	private OnlinecarRealtimeVehicleService onlinecarRealtimeVehicleService;
	@Autowired
	private OnlinecarRegistrationInfoService onlinecarRegistrationInfoService;
	@Autowired
	private OnlinecarMouthViolationTypeService onlinecarYearlyViolationTypeService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void onlinecarService() {
		log.info("Onlinecar Server Start!");
		onlinecarCurrentDistrictVehicleRankService.query("1");
		onlinecarCurrentDistrictVehicleRankService.query("2");
		onlinecarCurrentDistrictVehicleRankService.query("3");
		onlinecarDailyBusinessService.query();
		onlinecarDailyHourVehicleTrendService.query();
		onlinecarEnterpriseBusinessRankService.query();
		onlinecarEnterpriseViolationRankService.query();
		onlinecarMonthlyDailyCarTrendService.query();
		onlinecarRealtimeVehicleService.query();
		onlinecarRegistrationInfoService.query();
		onlinecarYearlyViolationTypeService.query();
		log.info("Onlinecar Server Finish!");
	}
	
	
	@Autowired
	private OverviewRealtimeTrafficService overviewRealtimeTrafficService;
	@Autowired
	private OverviewRealtimeTransportationService overviewRealtimeTransportationService;
	@Autowired
	private OverviewTodayHourTrafficTrendService overviewTodayHourTrafficTrendService;
	@Autowired
	private OverviewTrafficEventService overviewTrafficEventService;
	@Autowired
	private OverviewYearlyTrafficTrendService overviewYearlyTrafficTrendService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void overviewService() {
		log.info("Overview Server Start!");
		overviewRealtimeTrafficService.query();
		overviewRealtimeTransportationService.query();
		overviewTodayHourTrafficTrendService.query();
		overviewTrafficEventService.query();
		overviewYearlyTrafficTrendService.query();
		log.info("Overview Server Finish!");
	}
	
	
	@Autowired
	private SubwayTodayHourTrafficTrendService subwayTodayHourTrafficTrendService;
	@Autowired
	private SubwayTodayLineTrafficRankService subwayDailyLineTrafficRankService;
	@Autowired
	private SubwayTodayStationTrafficRankService SubwayTodayStationTrafficRankService;
	@Autowired
	private SubwayLineBusinessRankService subwayLineBusinessRankService;
	@Autowired
	private SubwayLineStationLoadService subwayLineLoadRankService;
	@Autowired
	private SubwayNetStatisticsInfoService subwayNetStatisticsInfoService;
	@Autowired
	private SubwayRealtimeTrafficService subwayRealtimeTrafficService;
	@Autowired
	private SubwayStationLoadRankService subwayStationLoadRankService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void SubwayService() {
		log.info("Subway Server Start!");
		subwayTodayHourTrafficTrendService.query();
		subwayDailyLineTrafficRankService.query();
		SubwayTodayStationTrafficRankService.query();
		subwayLineBusinessRankService.query();
		subwayLineLoadRankService.query("01");
		subwayLineLoadRankService.query("02");
		subwayNetStatisticsInfoService.query();
//		subwayRealtimeTrafficService.query("0001");
//		subwayRealtimeTrafficService.query("0002");
		line_codes.forEach(l->subwayRealtimeTrafficService.query(l));
		subwayStationLoadRankService.query();
		log.info("Subway Server Finish!");
	}
	
	
	@Autowired
	private TaxiTodayAreaVehicleRankService TaxiTodayAreaVehicleRankService;
	@Autowired
	private TaxiDailyBusinessService TaxiDailyBusinessService;
	@Autowired
	private TaxiTodayDistrictOdService TaxiDailyDistrictOdService;
	@Autowired
	private TaxiTodayLoadStatusTrendService TaxiDailyHourVehicleTrendService;
	@Autowired
	private TaxiMonthEnterpriseViolationRankService TaxiEnterpriseViolationRankService;
	@Autowired
	private TaxiMonthBusinessPercarTrendService TaxiMonthlyDailyCarTrendService;
	@Autowired
	private TaxiRealtimeVehicleService TaxiRealtimeVehicleService;
	@Autowired
	private TaxiMonthViolationTypeService TaxiYearlyViolationTypeService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void TaxiService() {
		log.info("Taxi Server Start!");
		TaxiTodayAreaVehicleRankService.query("1");
		TaxiTodayAreaVehicleRankService.query("2");
		TaxiTodayAreaVehicleRankService.query("3");
		TaxiDailyBusinessService.query();
		TaxiDailyDistrictOdService.query();
		TaxiDailyHourVehicleTrendService.query();
		TaxiEnterpriseViolationRankService.query();
		TaxiMonthlyDailyCarTrendService.query();
		TaxiRealtimeVehicleService.query();
		TaxiYearlyViolationTypeService.query();
		log.info("Taxi Server Finish!");
	}
}
